package com.bwie.service.impl;

import com.bwie.common.domain.Region;
import com.bwie.common.domain.Store;
import com.bwie.common.domain.request.StoreRequest;
import com.bwie.common.result.PageResult;
import com.bwie.mapper.StoreMapper;
import com.bwie.service.StoreService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @className: StoreServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: 刘茂锴
 * @date: 2025/10/13 13:54
 */
@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    private StoreMapper storeMapper;

    //门店列表
    @Override
    public PageResult<Store> storeList(StoreRequest storeRequest) {
        PageHelper.startPage(storeRequest.getPageNum(), storeRequest.getPageSize());
        List<Store> list=storeMapper.storeList(storeRequest);
        PageInfo<Store> info = new PageInfo<>(list);
        return PageResult.toPageResult(info.getTotal(),info.getList());
    }

    //门店区域下拉框
    @Override
    public List<Region> regionList() {
        return storeMapper.regionList();
    }
}
